package com.gw2.gw2world.web.server.model;

import java.util.ArrayList;
import java.util.List;

public class Recipe {
	public static enum Disciplines {
		MYSTIC_FORGE,
		ARMORSMITH,ARTIFICER,CHEF,HUNTSMAN,JEWELER,LEATHERWORKER,TAILOR,WEAPONSMITH
	};
	private static final int QUANTITY_MASK=0x000000ff, ITEM_MASK=0xffffff00;
	int id; //item ID
	List<Integer> ingredientAndQuantity;
	public Recipe() {
		ingredientAndQuantity=new ArrayList<Integer>(4);
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public List<Integer> getIngredientAndQuantity() {
		return ingredientAndQuantity;
	}
	public void addIngredientAndQuantity(int item_id, short quantity) {
		int result=item_id<<2;
		result+=quantity;
		ingredientAndQuantity.add(result);
	}
	public int getIngredientCount(){return ingredientAndQuantity.size();}
	public int getIngredientAt(int i) {
		if(i>4 || i<0) return 0;
		int tmp=ingredientAndQuantity.get(i);
		tmp=tmp&ITEM_MASK;
		tmp=tmp>>2;
		return tmp;
	}
	public int getQuantityAt(int i) {
		if(i>4 || i<0) return 0;
		return ingredientAndQuantity.get(i)&QUANTITY_MASK;
	}
}
